<template>
  <!-- 收入 合同统计-->
  <div v-auths="['contractCount']">
    <div class="topBox">
      <p class="name">收入</p>
      <p class="tip">数据截至：{{ date }} 00:00</p>
    </div>
    <div class="list">
      <!-- <div class="item">
        <img
          :src="require('/public/img/contract_icon1.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">合同总数</p>
          <p class="num">{{ countData.contractYearNum ?? 0 }}</p>
        </div>
      </div> -->
      <div
        class="item"
        style="background-image: linear-gradient(135deg, #ffa846 50%, #ffdeba)"
      >
        <div class="info">
          <img
            :src="require('/public/img/home/icon1.webp')"
            alt=""
            class="img"
          />
          <p class="name">合同总额</p>
        </div>
        <p class="num">{{ countData.contractYearMoney }}</p>
      </div>
      <!-- <div class="item">
        <img
          :src="require('/public/img/contract_icon3.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">合同月新增</p>
          <p class="num">{{ countData.contractMonthNum ?? 0 }}</p>
        </div>
      </div> -->
      <div
        class="item"
        style="background-image: linear-gradient(135deg, #ffcf53 50%, #ffebb7)"
      >
        <div class="info">
          <img
            :src="require('/public/img/home/icon2.webp')"
            alt=""
            class="img"
          />
          <p class="name">合同月总额</p>
        </div>
        <p class="num">{{ countData.contractMonthMoney }}</p>
      </div>
      <div
        class="item"
        style="background-image: linear-gradient(135deg, #03c856 50%, #44ff93)"
      >
        <div class="info">
          <img
            :src="require('/public/img/home/icon3.webp')"
            alt=""
            class="img"
          />
          <p class="name">客户总数</p>
        </div>
        <p class="num">{{ countData.customerYearNum }}</p>
      </div>
      <div
        class="item"
        style="background-image: linear-gradient(135deg, #fa746b 50%, #ffbbb6)"
      >
        <div class="info">
          <img
            :src="require('/public/img/home/icon4.webp')"
            alt=""
            class="img"
          />
          <p class="name">客户月新增</p>
        </div>
        <p class="num">{{ countData.customerMonthNum }}</p>
      </div>
      <div
        class="item"
        style="background-image: linear-gradient(135deg, #0d4ae8 50%, #6a94ff)"
      >
        <div class="info">
          <img
            :src="require('/public/img/home/icon5.webp')"
            alt=""
            class="img"
          />
          <p class="name">应收总额</p>
        </div>
        <p class="num">{{ countData.planCollectMoney }}</p>
      </div>
      <div
        class="item"
        style="background-image: linear-gradient(135deg, #7154e7 50%, #bdacff)"
      >
        <div class="info">
          <img
            :src="require('/public/img/home/icon6.webp')"
            alt=""
            class="img"
          />
          <p class="name">实收总额</p>
        </div>
        <div class="value">
          <p class="num">
            {{ countData.customerPaymentMoney }}
          </p>
          <!-- <p class="small">({{ countData.balanceMoney }})</p> -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { changeMoneyUnit1 } from "@/utils/changeMoneyUnit"
export default {
  name: "contractCount",
  title: "合同统计",
  icon: "el-icon-s-data",
  description: "合同统计信息展示",
  data () {
    return {
      countData: {},
      date: this.$TOOL.dateFormat(new Date(), "yyyy-MM-dd"),
    }
  },
  created () {
    this.getContractCountData()
  },
  methods: {
    async getContractCountData () {
      let { data } = await this.$API.contract.getContractCountData.get()
      this.countData = data
      this.countData.contractYearMoney = changeMoneyUnit1(this.countData.contractYearMoney)
      this.countData.contractMonthMoney = changeMoneyUnit1(this.countData.contractMonthMoney)
      this.countData.planCollectMoney = changeMoneyUnit1(this.countData.planCollectMoney)
      this.countData.customerPaymentMoney = changeMoneyUnit1(this.countData.customerPaymentMoney)
      // this.countData.balanceMoney = changeMoneyUnit1(this.countData.balanceMoney)

    },
  },
};
</script>

<style lang="scss" scoped>
.topBox {
  display: flex;
  align-items: baseline;
  margin-top: 20px;
  margin-bottom: 10px;
  .name {
    margin-right: 10px;
    font-weight: 600;
    font-size: 18px;
  }
  .tip {
    font-size: 14px;
    color: #999;
  }
}

.list {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 20px;

  // overflow-x: auto;
}
.item {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  flex-basis: calc(100% / 6);
  min-width: 170px;
  height: 100px;
  margin: 0 10px 10px 0;
  padding: 10px;
  border-radius: 4px;
  // border: 1px solid #e6e6e6;
  background: #fff;
  color: #fff;

  &:last-child {
    margin-right: 0;
  }
  .info {
    display: flex;
    align-items: center;
    margin-left: 6px;
  }
  .img {
    transform: scale(0.6);
  }
  .name {
    white-space: nowrap;
    font-size: 14px;
    // color: #999;
  }
  .value {
    display: flex;
    align-items: flex-end;
  }
  .num {
    white-space: nowrap;
    font-weight: 600;
    font-size: 18px;
  }
  .small {
    white-space: nowrap;
    font-size: 14px;
  }
}

@media screen and (max-width: 1200px) {
  .list {
    flex-wrap: wrap;
    .item {
      flex-basis: calc(100% / 3 - 10px) !important;
      &:nth-child(3n) {
        margin-right: 0;
      }
    }
  }
}
</style>
